<%@page import="java.lang.reflect.Array"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="reserveheader.jsp"%>
	<div id="real_contents">
<%@ page import="java.util.Arrays"%>
<%
	List<HashMap> list = null;
	
	String[] summer = {"비수기","여름성수기","겨울성수기"};

	if(request.getAttribute("list") !=null){
		list = (List<HashMap>)request.getAttribute("list");
	}
	
	Calendar cal = Calendar.getInstance();
	
	int yr = cal.get(Calendar.YEAR);
	int mon = cal.get(Calendar.MONTH);
	int day = cal.get(Calendar.DATE);
	
	if(request.getParameter("year") != null){
		yr = Integer.parseInt(request.getParameter("year"));
	}
	if(request.getParameter("month") != null){
		mon = Integer.parseInt(request.getParameter("month"));
	}
	if(request.getParameter("day") != null){
		day = Integer.parseInt(request.getParameter("day"));
	}
	
%>
<script language="javascript">
function RoomInfoPop(rid) {
	var winWidth = 700;
	var winHeight = 300;
	var winPosLeft = (screen.width - winWidth) / 2;
	var winPosTop = (screen.height - winHeight) / 2;

	var winOpt = 'toolbar=no,location=no,directory=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+winWidth+',height='+winHeight+',top=0,left=0';
	url = '<%=path%>/reserveinfo.rv?room='+rid;
	window.open(url, 'popwin', winOpt + '');
}

function Reserve() {
	form = document.RealFm;
	
	var str = false;
	var i = 0;

	for(i=5; i<form.elements.length; i++) {
		if(form.elements[i].name=="room_chk" && form.elements[i].checked==true){
			str = true;
		}
	}
	if(str==false) {
		alert("예약하실 객실을 선택하세요!");
		return;
	}
	form.submit();
}

var summer = new Array();
summer[0] = '비수기';
summer[1] = '여름성수기';
summer[2] = '겨울성수기';

var summerprice = new Array();
<%for(int i=0;i<list.size();i++){%>
	summerprice[<%=i%>] = new Array();
	<%for(int j=0;j<3;j++){%>
		summerprice[<%=i%>][<%=j%>] = new Array();
	<%}
}%>
<%for(int i=0;i<list.size();i++){
	for(int j=0;j<3;j++){%>
		<%if(j==0){%>
			summerprice[<%=i%>][0] = new Array('<%=list.get(i).get("R_WEEK")%>','<%=list.get(i).get("R_WEEKEND")%>');
		<%} else if(j==1){%>
			summerprice[<%=i%>][1] = new Array('<%=list.get(i).get("R_SWEEK")%>','<%=list.get(i).get("R_SWEEKEND")%>');
		<%} else if(j==2){%>
			summerprice[<%=i%>][2] = new Array('<%=list.get(i).get("R_WWEEK")%>','<%=list.get(i).get("R_WWEEKEND")%>');
		<%}
	}
}%>
function pirceSet(n,t,li_name) {
	for (var i = 1; i <= t; i++) {
		var objli = document.getElementById(li_name+ "_" +i);
		if (i == n) {
			objli.className = "on";
		} else {
			objli.className = "";
		}
	}
	document.getElementById("priceTitle").innerHTML = summer[n-1];
	for(var j=0; j< <%=list.size()%>; j++) {
		document.getElementById(j+"_price1").innerHTML = summerprice[j][n-1][0]+"원";
		document.getElementById(j+"_price2").innerHTML = summerprice[j][n-1][1]+"원";
	}
}

window.onload = function() {
	pirceSet(1,3,'trfelement_navi');
}
function BackPage(){
	var movedata = document.movedata;
	movedata.year.value = <%=yr%>;
	movedata.month.value = <%=mon%>;
	movedata.action="<%=path%>/reservepage.rv";
	movedata.method="post";
	movedata.submit();
}
</script>
<form name="movedata">
	<input type="hidden" name="year">
	<input type="hidden" name="month">
	<input type="hidden" name="day">
	<input type="hidden" name="room">
</form>

<form name="RealFm" action="<%=path %>/reserveconfirm.rv" method="post" onsubmit="return false;">
	<input type="hidden" name="date_from" value="<%=yr%>/<%=mon%>/<%=day%>">
	
	<div id="real_bigstep02">
	
	<div id="bigdate_title">
	<img src="<%=path%>/images/1title.gif" border="0" alt=""></div>
	
	<div id="bigdate_dateL"></div>
	<div id="bigdate_date">
		<strong><%=yr %>년 <%=mon+1%>월 <%=day %>일 부터</strong>
		<%for(int i=0; i<4; i++){%>
			<input type="radio" name="days" value="<%=i+1 %>" <%if(i==0){%>checked="checked"<%} %> class="radio"> <%=i+1%>박<%=i+2%>일
		<%} %>
	</div>
	
	<div id="bigdate_dateR"></div>
	<div id="bigdate_title2">
	<img src="<%=path%>/images/2title.gif" border="0" alt=""></div>
	
	<div id="bigdate_text">
	<span class="font_007cc9">이용 인원수</span>를 <img src="<%=path%>/images/check.gif" alt=""> 체크하시고, 아래 <img src="<%=path%>/images/btn_ok2.gif" alt="">을 클릭하여 주십시오. </div>
	
	<div id="trfelement_navi">
		<ul>
			<%for(int i=0; i<summer.length; i++){%>
				<li id="trfelement_navi_<%=i+1 %>" <%if(i==0){%>class="on"<%} else {%>class=""<%} %>><a href="javascript:pirceSet(<%=i+1%>,3,'trfelement_navi');"><strong><%=summer[i] %></strong></a></li>
			<%} %>
		</ul>
	</div>
	<div id="trfelement_box">
		<div id="trfelement_box_1">
			<div class="step02_roomprice">
				<div class="price_table">
					<table cellpadding="0" cellspacing="0" border="0" width="100%" class="pricetable" summary="">
						<colgroup>
						<col width="19%">
						<col width="7%">
						<col width="7%">
						<col width="11%">
						<col width="8%">
						<col width="11%">
						
						<col width="11%">
						
						<col width="11%">
						<col width="15%">
						</colgroup>
						<thead>
						<tr>
							<th rowspan="2">객실명</th>
							<th rowspan="2">기준<br>
							인원</th>
							<th rowspan="2">최대<br>
							인원</th>
							<th rowspan="2">인원<br>
							선택</th>
							<th rowspan="2">면적</th>
							<th colspan="2" id="priceTitle">비수기</th>
							<th rowspan="2" class="border_Rno">객실정보</th>
						</tr>
						<tr>
							<th>주중</th>
							
							<th>주말</th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<%for(int i=0;i<list.size();i++) {%>
								<td class="roomname">
									<input type="checkbox" class="check" name="room_chk" value="<%=list.get(i).get("R_NO") %>" <%if(i==0){%>checked=""<%} %>>
									<%=list.get(i).get("R_NAME") %>
								</td>
								<td><%=list.get(i).get("R_MIN") %>명</td>
								<td><%=list.get(i).get("R_MAX") %>명</td>
								<td>
									<select name="person_num_<%=list.get(i).get("R_NO") %>" id="<%=list.get(i).get("R_NO") %>">
										<%for(int j=Integer.parseInt(list.get(i).get("R_MIN").toString());j<=Integer.parseInt(list.get(i).get("R_MAX").toString());j++) {%>
											<option value="<%=j%>"><%=j%></option>
										<%} %>
									</select>
								</td>
								<td><%=list.get(i).get("R_SIZE") %>평</td>
								<td id="<%=i %>_price1">0</td>
								
								<td id="<%=i %>_price2">0</td>
								
								<td class="border_Rno">
									
									<a href="javascript:RoomInfoPop('<%=list.get(i).get("R_NO") %>')" onfocus="this.blur()">
								<img src="<%=path%>/images/room_view.gif" alt="">
									</a>
									
								</td>
								<%} %>
							</tr>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div id="stpe05_next">
		<a href="javascript:BackPage()"><img src="<%=path%>/images/btn_back.gif" border="0" alt=""></a>
		<a href="javascript:Reserve()"><img src="<%=path%>/images/btn_ok2.gif" border="0" alt=""></a>
	</div>
</form>
</div>
<%@ include file="reservefooter.jsp"%>